import csv
from matplotlib import pyplot as plt

import numpy as np

# filename = open('agent_log.csv')
# readfile = csv.reader(filename)
# filedata = list(readfile)
# len_hang = len(filedata)
# len_lie = len(filedata[0])
#
# x = list()
# y = list()
#
# x_list = []
# y_list = []
#
# for i in range(10):
#     x = list()
#     y = list()
#     x_list.append(x)
#     y_list.append(y)
#
# for i in range(1, len_hang):
#     if filedata[i][2] == 0:
#         x.append(filedata[i][1])
#         y.append(filedata[i][4])
#     x_list[int(filedata[i][2])].append(filedata[i][1])
#     y_list[int(filedata[i][2])].append(filedata[i][4])
#
# for i in range(10):
#     plt.plot(x_list[i], y_list[i])
# plt.show()


def trick_to_time(trick_step):
    """
    360模拟一天，一个trick表示2分钟
    :param trick_step: 时间步
    :return: [hour, min]
    """
    #  360模拟一天，一个trick表示2分钟
    trick_step %= 360
    time_hour = int(trick_step / 30)
    time_min = trick_step % 30 * 2
    return time_hour


filename = open('agent_log_33.csv')
readfile = csv.reader(filename)
filedata = list(readfile)
len_hang = len(filedata)
len_lie = len(filedata[0])

x = list()
y = list()

x_list = []
y_list = []

for i in range(10):
    x = list()
    y = list()
    x_list.append(x)
    y_list.append(y)

final_list = []
clk_i = 0
for j in range(9):
    x = list()
    y = list()
    z = list()
    for i in range(1, len_hang):
        if int(filedata[i][2]) == j:
            x.append(int(filedata[i][0]))
            y.append(trick_to_time(int(filedata[i][-3])))
            z.append(trick_to_time(int(filedata[i][-4])))
    plt.subplot(3, 3, j + 1)
    plt.plot(x, y)
    plt.plot(x, z)

plt.title("update_time")
plt.show()

